﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="juhiload", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Juhiload))]
    public class JuhiloadSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IJuhiload clazz;
        
        public JuhiloadSerializer(IJuhiload clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("juhiloanr");
            if (clazz.Juhiloanr!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Juhiloanr))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Juhiloanr");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("loatyyp");
            if (clazz.Loatyyp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Loatyyp))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Loatyyp");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kategooriad");
            if (clazz.Kategooriad!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kategooriad))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kategooriad");
            }
            Writer.WriteEndElement();
            if (clazz.Eritingimused!=null) {
                Writer.WriteStartElement("eritingimused");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eritingimused))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("valjaantud");
            if (clazz.Valjaantud!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Valjaantud))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Valjaantud");
            }
            Writer.WriteEndElement();
            if (clazz.Katteantud!=null) {
                Writer.WriteStartElement("katteantud");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Katteantud))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KehtivLopp!=null) {
                Writer.WriteStartElement("kehtiv_lopp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KehtivLopp))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("staatus");
            if (clazz.Staatus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Staatus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Staatus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "juhiloanr")) {
                goto juhiloanr;
            }
            else {
                if ((Reader.LocalName == "loatyyp")) {
                    goto loatyyp;
                }
                else {
                    if ((Reader.LocalName == "kategooriad")) {
                        goto kategooriad;
                    }
                    else {
                        if ((Reader.LocalName == "eritingimused")) {
                            goto eritingimused;
                        }
                        else {
                            if ((Reader.LocalName == "valjaantud")) {
                                goto valjaantud;
                            }
                            else {
                                if ((Reader.LocalName == "katteantud")) {
                                    goto katteantud;
                                }
                                else {
                                    if ((Reader.LocalName == "kehtiv_lopp")) {
                                        goto kehtiv_lopp;
                                    }
                                    else {
                                        if ((Reader.LocalName == "staatus")) {
                                            goto staatus;
                                        }
                                        else {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        juhiloanr:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>juhiloanr");
            }
            clazz.Juhiloanr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("juhiloanr")).Value;
            goto START;
        loatyyp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>loatyyp");
            }
            clazz.Loatyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("loatyyp")).Value;
            goto START;
        kategooriad:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>kategooriad");
            }
            clazz.Kategooriad = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kategooriad")).Value;
            goto START;
        eritingimused:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>eritingimused");
            }
            clazz.Eritingimused = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eritingimused")).Value;
            goto START;
        valjaantud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>valjaantud");
            }
            clazz.Valjaantud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("valjaantud")).Value;
            goto START;
        katteantud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>katteantud");
            }
            clazz.Katteantud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("katteantud")).Value;
            goto START;
        kehtiv_lopp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>kehtiv_lopp");
            }
            clazz.KehtivLopp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kehtiv_lopp")).Value;
            goto START;
        staatus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhiload>staatus");
            }
            clazz.Staatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("staatus")).Value;
            goto START;
        }
    }
}
